import java.util.Scanner;

public class Question1 {

    public static boolean isvalid(String numstr) {
        final String[] s = numstr.split(" ");
        int[] nums = new int[s.length];
        for (int i = 0; i < s.length; i++) {
            nums[i] = Integer.parseInt(s[i]);
        }
        // 检测
        if (nums[0] >= 10 && nums[nums.length-1] >= 10) {
            boolean _isvalid = true;
            for (int i = 1; i < nums.length-1; i++) {
                final int num = nums[i];
                if (num >= 10) {
                    _isvalid = false;
                    break;
                }
            }
            if (_isvalid) {
                return true;
            }
        }

        if (nums[0] < 10 && nums[nums.length-1] < 10) {
            boolean _isvalid = true;
            for (int i = 1; i < nums.length-1; i++) {
                final int num = nums[i];
                if (num < 10) {
                    _isvalid = false;
                    break;
                }
            }
            if (_isvalid) {
                return true;
            }
        }
        // 检测交替的方式
        boolean valid = true;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] >= 10 && nums[i-1] >= 10) {
                valid = false;
                break;
            }
            if (nums[i] < 10 && nums[i-1] < 10) {
                valid = false;
                break;
            }
        }

        return valid;
    }

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        while (scanner.hasNext()) {
            String line = scanner.nextLine();
            sb.append(isvalid(line));
            sb.append(" ");
        }
        if (sb.charAt(sb.length()-1) == ' ') {
            sb.deleteCharAt(sb.length() - 1);
        }
        System.out.print(sb.toString());
    }
}
